package com.alingrad.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import com.alingrad.R;

public class XMLLayout extends FrameLayout {
	
	public XMLLayout(Context context) {
		this(context, null, 0);
	}

	public XMLLayout(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public XMLLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		TypedArray a = getContext().obtainStyledAttributes(attrs, 
				R.styleable.XMLLayout);
		int id = a.getResourceId(R.styleable.XMLLayout_src, -1);
		if (id > 0)
			setView(id);
		a.recycle();
	}
	
	public View setView(int resId) {
		LayoutInflater li = LayoutInflater.from(getContext());
		View view = li.inflate(resId, this, true);
		return view;
	}
	
}
